package com.wenzi.rule.verification.actuator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.BeanResolver;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ExecutorStrategy {
    private Map<String, Actuator> actuatorMap = new HashMap<>();

    @Autowired
    private BeanResolver resolver;

    @Autowired
    private void initActuator(List<Actuator> actuators) {
        for (Actuator actuator : actuators) {
            actuatorMap.put(actuator.getType(), actuator);
        }
    }

    public void process(String configType,String configName,Object form) {
        actuatorMap.get(configType).execute(configName,form,resolver);
    }
}
